import { createRouter, createWebHistory } from 'vue-router'
import Home from '../views/Home.vue'
import HomeView from '../views/HomeView.vue'
import LayoutView from '../views/LayoutView.vue'
//路由的配置数组
//path: 路由路径 必须以/开头
//component 对应的路由组件你
const routes = [
  {
    path: '/',
    name: 'HomeView',
    component: HomeView
  },
  {
    path: '/HomeDemo',
    name: 'HomeDemo',
    component: Home
  },
  {
    path: '/LayoutView',
    name: 'LayoutView',
    component: LayoutView
  },
  {
    path: '/about',
    name: 'about',
    // 按需引用，如果没有访问到该组件就不会加载这个页面，节约性能
    component: () => import('../views/AboutView.vue')
  }
]

//创建路由对象
//createWebHistory 和 createWebHashHistory 后者会在请求地址上拼接一个/#
const router = createRouter({
  history: createWebHistory(process.env.BASE_URL),
  routes
})

export default router
